class ChartResult(list):
    def __init__(self, parent):
        self._open = None
        self._high = None
        self._low = None
        self._volume = 0
        self._close= 0
    
    def SetValues(self, row):
        try:
            vals = row.split(',')
            self._close = float(vals[1])
            self.append(self._close)
            self._high = float(vals[2])
            self.append(self._high)
            self._low = float(vals[3])
            self.append(self._low)
            self._open = float(vals[4])
            self.append(self._open)
            self._volume = float(vals[5])
            self.append(self._volume)
            if self._close >= self._open:
                self.append(True)
            else:
                self.append(False)
            self._change = abs(self._open - self._close)
            self.append(self._change)
            self._range = self._high - self._low
            self.append(self._range)
            self._diff = self._range - self._change
            self.append(self._diff)
        except BaseException, e:
            print("ChartResult.SetValues Error %s", e)
    
    def UpdateSum(self, result):
        try:
            if result._open is None:
                result._open = self._open
                result._high = self._high
                result._low = self._low
            else:
                if result._high < self._high:
                    result._high = self._high
                if result._low > self._low:
                    result._low = self._low
            result._volume = result._volume + self._volume
            result._close = self._close
            
        except BaseException, e:
            print("ChartResult.UpdateSum Error %s", e)   
    
    def Update(self, start, marketOpenMinute, interval, row, isFirstRow, result):
        try:
            self.SetValues(row)
            if max is not None:
                self.UpdateSum(result)
        except BaseException, e:
            print("ChartResult.Update Error %s", e)
            
    